/**
* 
* ====================================================================
*
* @author apov <apov@ymail.com>
*/ 
// SessionSync.h
//

#pragma once

#include <BaseDefine.h>
#include <Thread.h>
#include "NetworkSession.h"

/**
* @class CSessionSync
*  - 
*/
class SessionSync : public NetworkSession{
	enum{
		DEF_LINGER_TIME=	0, //second	
	};	

public:
	virtual bool initialize( Socket socket, bool isBlock = false );
	virtual int read_handler( int recv_size = 0 );
	virtual int write_handler( int write_size = 0 ){ return 0; }
	virtual void close_handler( int type, const char* caller_name = 0);	

	virtual int write( char* data, size_t size );
	virtual int write( char* data, size_t size, bool immediate );
	virtual int write( bool lock = true );	
	
	virtual LumpData* getRecvBuffer(){ return (LumpData*)&recv_buffer_; }

	virtual void set_parser_type( size_t parser_type );

	void shutdown();

	SessionSync();
	virtual ~SessionSync();

protected:	
	
private:
	CLock lock_;	
	
	LumpData recv_buffer_;	
	LumpData send_buffer_;	
};
